<html ng-app>
  <head>
    <script src="../lib/angular.min.js"></script>
    <script src="../generatedParser.js"></script>
    <script src="../shared.js"></script>
    <script src="../teacher.js"></script>
    <script src="../student.js"></script>
    <script src="../data.js"></script>
    <script src="../strings.js"></script>
    <script src="demonstration.js"></script>

    <script>

    </script>
  </head>

  <body ng-controller="TestCtrl">
    <table border="0">
      <tr>
        <td> <a href="shared_tests.html"> Shared tests </a> </td>
        <td> <a href="teacher_tests.html"> Teacher tests </a> </td>
        <td> <a href="student_tests.html"> Student tests </a> </td>
        <td> <a href="end_to_end_tests.html"> End to end tests </a> </td>
        <td> <b> Demonstration </b> </td>
      </tr>
    </table>
    <h4>Demonstration of the oppia logic widget.</h4>

    <p><center><u>Student's section </u></center></p>

    <p>Assuming {{assumptionsDisplay}}, prove that {{targetDisplay}}</p>
    <table>
      <tr>
        <td> <textarea ng-model="proofString" ng-trim="false" rows="10" cols="50"></textarea> </td>
        <td valign="top"> 
          <p>
            <button ng-click="buildProof()">Build</button> 
            <font color="red">{{buildError}}</font> 
            <font color="green" ng-show="buildSuccess">Success</font>
          </p>
          <p>
            <button ng-click="checkProof()">Check</button>
            <font color="red">{{checkError}}</font> 
            <font color="green" ng-show="checkSuccess">Correct!</font>
          </p>
        </td>
      </tr>
    </table>

    <!-- line <input type="text" ng-model="line"> mistake <input type="text" ng-model=mistakeName>
    <button ng-click="localCheck()">Check</button> {{localCheck}} -->

    <hr>
    <p></p>
    <p><center><u>Teacher's section </u></center></p>

    <b>Question </b><button ng-click="submitQuestion()">Submit</button>
    <font color="green" ng-show="questionSuccess">Success</font>
    <font color="red" ng-hide="questionSuccess">Failure</font>
    <p>
      Assumptions: <input type="text" ng-model="assumptionsString" size="30"> Target: <input type="text" ng-model="targetString" size="30"> 
      <font color="red"> {{questionError}} </font>
    </p>

    <b>Line Templates </b><button ng-click="submitLineTemplates()">Submit</button>
    <font color="green" ng-show="lineTemplateSuccess">Success</font>
    <font color="red" ng-hide="lineTemplateSuccess">Failure</font>
    <table>
      <tr>
        <td> Name </td>
        <td> Display </td>
        <td> Antecedents </td>
        <td> Results </td>
        <td> Variables </td>
        <td> Error 1 </td>
        <td> Error 2 </td>
      </tr>
      <tr ng-repeat="i in lineTemplateIndexer">
        <td> <input type="text" ng-model="lineTemplateStrings[i].name" size="15"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].reader_view" size="40"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].antecedents" size="6"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].results" size="6"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].variables" size="6"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].errors[0]" size="15"></td>
        <td> <input type="text" ng-model="lineTemplateStrings[i].errors[1]" size="15"></td>
        <td> <font color="red"> {{LineTemplateErrors[i]}} </font> </td>
      </tr>
    </table>

    <p></p>
    <b>Mistake Table: Layout</b> <button ng-click="submitLayoutMistakes()">Submit</button>
    <font color="green" ng-show="layoutMistakeSuccess">Success</font>
    <font color="red" ng-hide="layoutMistakeSuccess">Failure</font>
    <table>
      <tr>
        <td> Name </td>
        <td> Occurs </td>
        <td> Message 1 </td>
      <tr>
      <tr ng-repeat="i in layoutMistakeIndexer">
        <td> <input type="text" ng-model="layoutMistakeStrings[i].name"></td>
        <td> <input type="text" ng-model="layoutMistakeStrings[i].occurs" size="50"></td>
        <td> <input type="text" ng-model="layoutMistakeStrings[i].message[0]" size="60"></td>
        <td> <font color="red"> {{layoutMistakeErrors[i]}} </font> </td> 
      </tr>
    </table>

    <p></p>
    <b>Mistake Table: Variables</b> <button ng-click="submitVariableMistakes()">Submit</button>
    <font color="green" ng-show="variableMistakeSuccess">Success</font>
    <font color="red" ng-hide="variableMistakeSuccess">Failure</font>
    <table>
      <tr>
        <td> Name </td>
        <td> Occurs </td>
        <td> Message 1 </td>
      <tr>
      <tr ng-repeat="i in variableMistakeIndexer">
        <td> <input type="text" ng-model="variableMistakeStrings[i].name"></td>
        <td> <input type="text" ng-model="variableMistakeStrings[i].occurs" size="50"></td>
        <td> <input type="text" ng-model="variableMistakeStrings[i].message[0]" size="60"></td>
        <td> <font color="red"> {{variableMistakeErrors[i]}} </font> </td> 
      </tr>
    </table>

    <p></p>
    <b>Mistake Table: Logic</b> <button ng-click="submitLogicMistakes()">Submit</button>
    <font color="green" ng-show="logicMistakeSuccess">Success</font>
    <font color="red" ng-hide="logicMistakeSuccess">Failure</font>
    <table>
      <tr>
        <td> Name </td>
        <td> Occurs </td>
        <td> Message 1 </td>
      <tr>
      <tr ng-repeat="i in logicMistakeIndexer">
        <td> <input type="text" ng-model="logicMistakeStrings[i].name"></td>
        <td> <input type="text" ng-model="logicMistakeStrings[i].occurs" size="50"></td>
        <td> <input type="text" ng-model="logicMistakeStrings[i].message[0]" size="60"></td>
        <td> <font color="red"> {{logicMistakeErrors[i]}} </font> </td> 
      </tr>
    </table>

    <p></p>
    <b>Mistake Table: Target</b> <button ng-click="submitTargetMistakes()">Submit</button>
    <font color="green" ng-show="targetMistakeSuccess">Success</font>
    <font color="red" ng-hide="targetMistakeSuccess">Failure</font>
    <table>
      <tr>
        <td> Name </td>
        <td> Occurs </td>
        <td> Message 1 </td>
      <tr>
      <tr ng-repeat="i in targetMistakeIndexer">
        <td> <input type="text" ng-model="targetMistakeStrings[i].name"></td>
        <td> <input type="text" ng-model="targetMistakeStrings[i].occurs" size="50"></td>
        <td> <input type="text" ng-model="targetMistakeStrings[i].message[0]" size="60"></td>
        <td> <font color="red"> {{targetMistakeErrors[i]}} </font> </td> 
      </tr>
    </table>

    <p></p>
    <b>Control Functions </b><button ng-click="submitControlFunctions()">Submit</button>
    <font color="green" ng-show="controlFunctionSuccess">Success</font>
    <font color="red" ng-hide="controlFunctionSuccess">Failure</font>
    <table>
      <tr><td>indentation(n)</td><td></td><td></td><td>Number of times line n is indented</td></tr>
      <tr><td>template(n)</td><td></td><td></td><td>Name of the template of line n</td></tr>
      <tr><td>antecedents(n)</td><td></td><td></td><td>Formulas line n assumes have been proved</td></tr>
      <tr><td>results(n)</td><td></td><td></td><td>Formulas proved by line n</td></tr>
      <tr><td>variables(n)</td><td></td><td></td><td>Free variables occuring in line n (as expressions)</td></tr>
      <tr><td>text(n)</td><td></td><td></td><td>Raw text of line n</td></tr>
      <tr><td>element(p, n)</td><td></td><td></td><td>The expression instantiating template variable p in line n</td></tr>
      <tr><td>num_lines()</td><td></td><td></td><td>Number of lines in the proof</td></tr>
      <tr><td>assumptions()</td><td></td><td></td><td>Formulas the student can assume in the problem</td></tr>
      <tr><td>target()</td><td></td><td></td><td>Formula the student has to prove in this problem</td></tr>
      <tr><td>question_variables()</td><td></td><td></td><td>Variables occurring in the question (as expressions)</td></tr>
      <tr><td>entry(i, S)</td><td></td><td></td><td>The ith entry of set of expressions S</td></tr>
      <tr><td>if(p,x,y)</td><td></td><td></td><td>If p is true this returns x, otherwise returns y</td></tr>
      <tr><td>substitute(p,x,a)</td><td></td><td>Replaces all instances of variable x in formula p with element a</td></tr>
      <tr ng-repeat="i in controlFunctionIndexer">
        <td> <input type="text" ng-model="controlFunctionStrings[i].LHS"></td>
        <td>=</td>
        <td> <input type="text" ng-model="controlFunctionStrings[i].RHS" size="50"></td>
        <td> <input type="text" ng-model="controlFunctionStrings[i].description" size="60"></td>
        <td> <font color="red"> {{controlFunctionErrors[i]}} </font> </td> 
      </tr>
    <table>
  </body>
</html>